#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>

bool validate_password(char* password) {
    int len = strlen(password);
    bool has_upper = false;
    bool has_lower = false;
    bool has_digit = false;
    if (len < 8) {
        return false;
    }

    for (int i = 0; i < len; i++) {
        if (password[i] >= 'A' && password[i] <= 'Z') {
            has_upper = true;
        }
        else if (password[i] >= 'a' && password[i] <= 'z') {
            has_lower = true;
        }
        else if (password[i] >= '0' && password[i] <= '9') {
            has_digit = true;
        }
    }

    if (!has_upper || !has_lower || !has_digit) {
        return false;
    }

    return true;
}

char* encrypt_password(char* password) {
    int len = strlen(password);
    char* changed_password = (char*)malloc(len + 1);

    for (int i = 0; i < len; i++) {
        if (password[i] >= 'a' && password[i] <= 'z') {
            changed_password[i] = 'a' + (password[i] - 'a' + 13) % 26;
        }
        else if (password[i] >= 'A' && password[i] <= 'Z') {
            changed_password[i] = 'A' + (password[i] - 'A' + 13) % 26;
        }
        else {
            changed_password[i] = password[i];
        }
    }
    changed_password[len] = '\0';
    return changed_password;
}

int main() {
    char password[50]; 
    printf("Enter a password: ");
    scanf("%s", password);
    char* encrypted_password = encrypt_password(password);
    if (validate_password(encrypted_password)) {
        printf("Accepted\n");
    }
    else {
        printf("Not accepted\n");
    }
    free(encrypted_password);
    return 0;
}
